package org.devknights.android.andlib.sms;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;

public abstract class SMSReciever extends BroadcastReceiver {

	public static final String SMS_EXTRA_NAME = "pdus";

	public void onReceive(Context context, Intent intent) {
		Bundle extras = intent.getExtras();

		if (extras != null) {
			Object[] smsExtra = (Object[]) extras.get(SMS_EXTRA_NAME);
			for (int i = 0; i < smsExtra.length; i++) {
				msgRecieved(SmsMessage.createFromPdu((byte[]) smsExtra[i]));
			}
		}
	}

	public abstract void msgRecieved(SmsMessage msg);

}